﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Microsoft.Drawing;
using TouchRC.Classes;
using System.IO;
using System.Reflection;

namespace TouchRC.Logic
{
    public enum ImageTypes
    {
        Plus,
        Cross,
        Tick,
        Background,
        BackgroundL,
        Cogs,
        MenuUp,
        MenuDown,
        Remote,
        metadata_back,
        metadata_play
    }

    public enum MediaIcons
    {
        GreenButton,
        player_end,
        player_start,
        player_fwd,
        player_pause,
        player_play,
        player_rew,
        player_stop,
        player_rec,
        info,
        arrow_left,
        arrow_right,
        arrow_up,
        arrow_down,
        ok,
        vol_up,
        vol_down,
        ch_up,
        ch_down,
        back,
        close,
        mute,
        radio
    }

    public class ImageFactory
    {
        private static string gfxPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), "gfx");
        //@"\Program Files\TouchRC\gfx\";

        private static string GetBitmapLocation(ImageTypes image)
        {
            string imageName = string.Empty;
            switch (image)
            {
                case ImageTypes.Tick:
                    {
                        imageName = "accept.png";
                        break;
                    }
                case ImageTypes.Plus:
                    {
                        imageName = "add.png";
                        break;
                    }
                case ImageTypes.Cross:
                    {
                        imageName = "delete.png";
                        break;
                    }
                case ImageTypes.Cogs:
                    {
                        imageName = "edit.png";
                        break;
                    }
                case ImageTypes.MenuUp:
                    {
                        imageName = "menu_up.png";
                        break;
                    }
                case ImageTypes.MenuDown:
                    {
                        imageName = "menu_down.png";
                        break;
                    }
                case ImageTypes.Background:
                    {
                        imageName = "background.png";
                        break;
                    }
                case ImageTypes.BackgroundL:
                    {
                        imageName = "background.png";
                        break;
                    }
                case ImageTypes.Remote:
                    {
                        imageName = "remote.gif";
                        break;
                    }
                default:
                    {
                        throw new NotImplementedException("Not Implemented that type of picture!!");
                    }
            }
            return Path.Combine(gfxPath, imageName);
        }

        public static Bitmap GetBitmap(ImageTypes image)
        {
            return new Bitmap(GetBitmapLocation(image));
        }

        public static IImage GetMenuOptionImage(MenuItemOption option)
        {
            IImage retVal;
            IImagingFactory factory = ImagingFactory.GetImaging();
            factory.CreateImageFromFile(Path.Combine(gfxPath, option.ToString() + ".png"), out retVal);

            return retVal;
        }

        public static IImage GetMediaImage(MediaIcons icon)
        {
            IImage retVal;
            IImagingFactory factory = ImagingFactory.GetImaging();
            factory.CreateImageFromFile(Path.Combine(gfxPath, icon.ToString() + ".png"), out retVal);

            return retVal;
        }

        public static IImage GetIImageImageType(ImageTypes image)
        {
            IImage retVal;
            IImagingFactory factory = ImagingFactory.GetImaging();
            factory.CreateImageFromFile(Path.Combine(gfxPath, image.ToString() + ".png"), out retVal);

            return retVal;
        }

        private static void scratch()
        {
            IImagingFactory factory = ImagingFactory.GetImaging();

                

        }
    }
}
